Thread: drawing and filling rectangles [gtk+]

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    1

    drawing and filling rectangles [gtk+]

    Hi guys. This question regards gtk+ gui development.
    This code:

    Code:
    PAINTSTRUCT ps;
    RECT lpRect;
    .....
    case WM_PAINT:
    {
    HDC hdc = BeginPaint(hwnd, &ps);
    GetClientRect(hwnd, &lpRect);
    HBRUSH Brush=CreateSolidBrush(RGB(0,0,0));
    lpRect.bottom = 30;
    FillRect(hdc, &lpRect, Brush);
    EndPaint(hwnd, &ps);
    }
    is win32 api working code for win32 app. Lets say my app is 200 px in high, so it fils 30 px from top border with black color. Another thing, that code is in Message Loop so any positions changes i'll do - this area is filled.

    Now, how to do same thing in gtk+? If i will use win api in gtk app (my app is for windows, yes) - it is not in message loop so it is useless, when app window gets repaint - it overrides it with default color of currently selected gtk theme.
    Thanks in advance

  2. #2
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    GTK uses callbacks rather than a user-defined message loop, so you'll need to register your function with the library.
    I'm too lazy to explain how, if you care to read up on it there's a tutorial here - it has a specific example on a callback for when the window is repositioned.
    Consider this post signed

Popular pages Recent additions subscribe to a feed

Tags for this Thread